#include "sequenceitem.h"

const char TRACK_CAPTION[] = "TRACK";
const char LIGHT_CAPTION[] = "LIGHT";

SequenceItem::SequenceItem(int delayMs, const QString & label,
                           SequenceItem::eventType typeOfEvent, int indexOfNext,
                           QObject *parent) :
   QObject(parent),
   m_delayMs(delayMs),
   m_label(label),
   m_indexOfNext(indexOfNext),
   m_type(typeOfEvent)
{
}

QString SequenceItem::serialize() const
{
   QString typeString, output;

   if (m_type == SequenceItem::LIGHT)
   {
      typeString = QString(LIGHT_CAPTION);
   }
   else if (m_type == SequenceItem::TRACK)
   {
      typeString =  QString(TRACK_CAPTION);
   }

   if (typeString != QString())
   {
      output = QString("%1  \"%2\"  %3  %4").
               arg( typeString).arg(m_label).arg(m_delayMs).arg(m_indexOfNext);
   }

   return output;
}

bool operator ==(const SequenceItem &left, const SequenceItem &right)
{
   return (left.delayMs() == right.delayMs()) &&
         (left.label() == right.label()) &&
         (left.indexOfNext() == right.indexOfNext()) &&
         (left.type() == right.type());
}
